﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DiscoveryLogic.DataServices.DataSources;
using DiscoveryLogic.UI.Layouts.ContentScreens;
using DiscoveryLogic.UI.Layouts.Models;

namespace DiscoveryLogic.UI.Layouts.Controls
{
    public partial class Enrollment529Form : UserControl
    {

        public Enrollment529Form()
        {
            InitializeComponent();
        }

        // Get/Set Methods
        public string FullName
        {
            get { return FullNameTextBox.Text; }
            set { FullNameTextBox.Text = value; }
        }

        public int Age
        {
            get 
            {
                int age = 0;

                try
                {
                    // TODO: Exception will be thrown if non-numeric char in text
                    age = Convert.ToInt16(AgeTextBox.Text);
                }
                catch  
                {
                    // can't convert age to int
                }

                return age; 
            }
            set { AgeTextBox.Text = value.ToString(); }
        }

        public Child.CollegeType CollegeSelection
        {
            get 
            {
                if ((bool)radioInState.IsChecked)
                {
                    return Child.CollegeType.InState;
                }
                else if ((bool)radioOutState.IsChecked)
                {
                    return Child.CollegeType.OutOfState;
                }
                else
                {
                    return Child.CollegeType.Private;
                }
            }
            set 
            {
                if (value == Child.CollegeType.InState)
                {
                    radioInState.IsChecked = true;
                }
                else if (value == Child.CollegeType.OutOfState)
                {
                    radioOutState.IsChecked = true;
                }
                else if (value == Child.CollegeType.Private)
                {
                    radioPrivate.IsChecked = true;
                }

                radioButton_Click(this, new RoutedEventArgs());
            }
        }

        public double InitialInvestment
        {
            get { return Convert.ToDouble(InitialInvestmentLabel.Text); }
            set { InitialInvestmentLabel.Text = value.ToString(); }
        }

        private void radioButton_Click(object sender, RoutedEventArgs e)
        {
            if ((bool)radioInState.IsChecked)
            {
                InitialInvestment = 20000;
            }
            else if ((bool)radioOutState.IsChecked)
            {
                InitialInvestment = 25000;
            }
            else
            {
                InitialInvestment = 30000;
            }
        }
    }
}
